<?php


namespace app\admin\logic;


use app\common\logic\BaseLogic;
use app\common\model\Appoint;
use app\common\model\Cate;

class AppointLogic extends BaseLogic
{
    public function listing($name,$limit)
    {

        $where = [];
        !empty($keyword) && $where['name'] = ['like', "%$name%"];
        $r = Appoint::where($where)->order('id','desc')->paginate($limit)->toArray();

        foreach ($r['data'] as $key=>['cid'=>$cid]){
            if (is_string($cid)){
                $cid = explode(',',$cid);
            }
            $name = Cate::whereIn('id',$cid)->column('name');
            $nams = implode('，',$name);
            $r['data'][$key]['cate_name'] = $nams;
        }
        return $r;
    }

    public function delete($ids)
    {
        $str = trim($ids,',');
        $_arr = explode(',',$str);
        $where[] = ['id','in',$_arr];
        $r = Appoint::where($where)->delete();
        return $r;
    }
}